//
//  ACEMeViewController.m
//  ACE
//
//  Created by zhangtao on 2018/8/7.
//  Copyright © 2018年 zt.td. All rights reserved.
//

#import "ACEMeViewController.h"
#import "ACEMeHeaderView.h"
#import "ACEMeTableViewCell.h"
#import "ACEEditInfoController.h"

#import "ACEMeUpdatePSDController.h"
#import "ACEMyOrderController.h"
#import "ACEMyPayWayViewController.h"
#import "ACEAddBankCardViewController.h"
#import "ACEHelpViewController.h"
#import "ACEMyAdvisorViewController.h"
#import "ACELinkUsViewController.h"

#import "ACEBalanceTableViewController.h"
#import "ACEIncomeController.h"
#import "ACEIncomeSetController.h"
@interface ACEMeViewController ()

@end

@implementation ACEMeViewController
{
    NSArray *controllers;
    NSArray *titles;
    NSArray *icons;
    NSString *rightArrowImg;
}
-(void)viewWillAppear:(BOOL)animated{
    self.navigationController.navigationBar.hidden = YES;
}

-(void)viewWillDisappear:(BOOL)animated{
    self.navigationController.navigationBar.hidden = NO;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"支付信息";
    if ([ACEPublicTool currentRoleIsStudent]) {
        rightArrowImg = @"greenRightArrow";
        titles = @[@"安全中心",@"支付方式",@"我的订单",@"需要帮助",@"我的导师",@"联系我们"];
        icons = @[@"安全中心",@"支付方式",@"我的订单",@"需要帮助",@"我的导师",@"学生-联系我们"];
        controllers = @[@"ACEMeUpdatePSDController",@"ACEMyPayWayViewController",@"ACEMyOrderController",@"ACEHelpViewController",@"ACEMyAdvisorViewController",@"ACELinkUsViewController"];
    }else{
        rightArrowImg = @"Rectangle 2 Copy 7";
        titles = @[@"余额",@"收入",@"安全",@"订单",@"帮助",@"设置",@"联系我们"];
        icons = @[@"余额",@"收入",@"安全",@"订单",@"帮助",@"设置",@"联系我们"];
        controllers = @[@"ACEBalanceTableViewController",@"ACEIncomeController",@"ACEMeUpdatePSDController",@"ACEMyOrderController",@"ACEHelpViewController",@"ACEIncomeSetController",@"ACELinkUsViewController"];
    }
    
    if (@available(iOS 11.0,*)) {
        self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    }else{
        self.automaticallyAdjustsScrollViewInsets = NO;
    }
    
    [self.tableView registerNib:[UINib nibWithNibName:@"ACEMeTableViewCell" bundle:nil] forCellReuseIdentifier:@"cell"];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
   // 5/3
    return ACEWidth*3/5;
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    ACEMeHeaderView *header = [[ACEMeHeaderView alloc]initWithFrame:CGRectMake(0, 0, ACEWidth, ACEWidth*3/5)];
    header.editBtnClick = ^{
        ACEEditInfoController *edit = [[ACEEditInfoController alloc]init];
        [self presentViewController:edit animated:YES completion:nil];
//        edit.hidesBottomBarWhenPushed = YES;
//        [self.navigationController pushViewController:edit animated:YES];
    };
    return header;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return titles.count;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 50;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  
    ACEMeTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    
    cell.title.text = titles[indexPath.row];
    cell.leftImageV.image = [UIImage imageNamed:icons[indexPath.row]];
    cell.rightArrow.image = [UIImage imageNamed:rightArrowImg];
 
    return cell;
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    UIViewController *controller = [[NSClassFromString(controllers[indexPath.row]) alloc]init];
    controller.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:controller animated:YES];
}

/*


/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
